home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / VBSamples / DirectPlay / DXVBMessenger / Client / frmCreate.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-10-08  |  6.5 KB  |  185 lines

  1. VERSION 5.00
  2. Begin VB.Form frmCreate 
  3.    BorderStyle     =   4  'Fixed ToolWindow
  4.    Caption         =   "Create a new account"
  5.    ClientHeight    =   3585
  6.    ClientLeft      =   45
  7.    ClientTop       =   285
  8.    ClientWidth     =   4680
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   3585
  13.    ScaleWidth      =   4680
  14.    ShowInTaskbar   =   0   'False
  15.    StartUpPosition =   1  'CenterOwner
  16.    Begin VB.TextBox txtVerify 
  17.       Height          =   285
  18.       IMEMode         =   3  'DISABLE
  19.       Left            =   60
  20.       PasswordChar    =   "*"
  21.       TabIndex        =   2
  22.       Top             =   2100
  23.       Width           =   4515
  24.    End
  25.    Begin VB.TextBox txtUserName 
  26.       Height          =   285
  27.       Left            =   60
  28.       TabIndex        =   0
  29.       Top             =   900
  30.       Width           =   4515
  31.    End
  32.    Begin VB.TextBox txtPassword 
  33.       Height          =   285
  34.       IMEMode         =   3  'DISABLE
  35.       Left            =   60
  36.       PasswordChar    =   "*"
  37.       TabIndex        =   1
  38.       Top             =   1500
  39.       Width           =   4515
  40.    End
  41.    Begin VB.TextBox txtServerName 
  42.       Height          =   285
  43.       Left            =   60
  44.       TabIndex        =   3
  45.       Top             =   2700
  46.       Width           =   4515
  47.    End
  48.    Begin VB.CommandButton cmdLogin 
  49.       Caption         =   "Create"
  50.       Default         =   -1  'True
  51.       Height          =   375
  52.       Left            =   3600
  53.       TabIndex        =   5
  54.       Top             =   3120
  55.       Width           =   1035
  56.    End
  57.    Begin VB.CommandButton cmdCancel 
  58.       Cancel          =   -1  'True
  59.       Caption         =   "Cancel"
  60.       Height          =   375
  61.       Left            =   2520
  62.       TabIndex        =   4
  63.       Top             =   3120
  64.       Width           =   1035
  65.    End
  66.    Begin VB.Label Label1 
  67.       BackStyle       =   0  'Transparent
  68.       Caption         =   "Verify Password:"
  69.       Height          =   195
  70.       Index           =   4
  71.       Left            =   60
  72.       TabIndex        =   10
  73.       Top             =   1860
  74.       Width           =   2955
  75.    End
  76.    Begin VB.Label Label1 
  77.       BackStyle       =   0  'Transparent
  78.       Caption         =   "UserName:"
  79.       Height          =   195
  80.       Index           =   1
  81.       Left            =   60
  82.       TabIndex        =   9
  83.       Top             =   660
  84.       Width           =   915
  85.    End
  86.    Begin VB.Label Label1 
  87.       BackStyle       =   0  'Transparent
  88.       Caption         =   "Password:"
  89.       Height          =   195
  90.       Index           =   2
  91.       Left            =   60
  92.       TabIndex        =   8
  93.       Top             =   1260
  94.       Width           =   915
  95.    End
  96.    Begin VB.Label Label1 
  97.       BackStyle       =   0  'Transparent
  98.       Caption         =   "Please type in your username, password and server to connect to, or click the 'Create Account' button..."
  99.       Height          =   495
  100.       Index           =   0
  101.       Left            =   60
  102.       TabIndex        =   7
  103.       Top             =   120
  104.       Width           =   4575
  105.    End
  106.    Begin VB.Label Label1 
  107.       BackStyle       =   0  'Transparent
  108.       Caption         =   "Server Name:"
  109.       Height          =   195
  110.       Index           =   3
  111.       Left            =   60
  112.       TabIndex        =   6
  113.       Top             =   2460
  114.       Width           =   1395
  115.    End
  116. Attribute VB_Name = "frmCreate"
  117. Attribute VB_GlobalNameSpace = False
  118. Attribute VB_Creatable = False
  119. Attribute VB_PredeclaredId = True
  120. Attribute VB_Exposed = False
  121. Option Explicit
  122. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  123. '  Copyright (C) 1999-2001 Microsoft Corporation.  All Rights Reserved.
  124. '  File:       frmCreate.frm
  125. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  126. Private Sub cmdCancel_Click()
  127.     Unload Me
  128. End Sub
  129. Private Sub cmdLogin_Click()
  130.     Dim AppDesc As DPN_APPLICATION_DESC
  131.     gfCreatePlayer = True
  132.     If txtServerName.Text = vbNullString Then 'They didn't enter a server name
  133.         MsgBox "You must enter a server name.", vbOKOnly Or vbInformation, "No server name."
  134.         Exit Sub
  135.     End If
  136.     If txtPassword.Text = vbNullString Then 'They didn't enter a password
  137.         MsgBox "You must enter a password.", vbOKOnly Or vbInformation, "No password."
  138.         Exit Sub
  139.     End If
  140.     If txtPassword.Text <> txtVerify.Text Then 'They didn't verify they're password correctly
  141.         MsgBox "The passwords do not match.", vbOKOnly Or vbInformation, "Passwords don't match."
  142.         Exit Sub
  143.     End If
  144.     If txtUserName.Text = vbNullString Then 'They didn't enter a user name
  145.         MsgBox "You must enter a user name.", vbOKOnly Or vbInformation, "No user name."
  146.         Exit Sub
  147.     End If
  148.     cmdLogin.Enabled = False
  149.     If gsServerName = vbNullString Then gsServerName = txtServerName.Text
  150.     'Now let's save the settings
  151.     SaveSetting gsAppName, "Startup", "ServerName", txtServerName.Text
  152.     SaveSetting gsAppName, "Startup", "Username", txtUserName.Text
  153.     If gfConnected And (gsServerName = txtServerName.Text) Then
  154.         'Save the username/password
  155.         gsPass = EncodePassword(txtPassword.Text, glClientSideEncryptionKey)
  156.         gsUserName = txtUserName.Text
  157.         CreatePlayer
  158.     Else
  159.         If gfConnected Then
  160.             InitDPlay 'Re-Initialize DPlay
  161.         End If
  162.         dpas.AddComponentString DPN_KEY_HOSTNAME, txtServerName.Text 'We only want to enumerate connections on this host
  163.         'First set up our application description
  164.         With AppDesc
  165.             .guidApplication = AppGuid
  166.         End With
  167.         'Save the username/password
  168.         gsPass = EncodePassword(txtPassword.Text, glClientSideEncryptionKey)
  169.         gsUserName = txtUserName.Text
  170.         On Error Resume Next
  171.         'Try to connect to this server
  172.         dpc.Connect AppDesc, dpas, dpa, 0, ByVal 0&, 0
  173.         If Err.Number <> 0 Then
  174.             MsgBox "This server could not be contacted.  Please check the server name and try again.", vbOKOnly Or vbInformation, "Not found."
  175.             cmdLogin.Enabled = True
  176.             Exit Sub
  177.         End If
  178.     End If
  179. End Sub
  180. Private Sub Form_Load()
  181.     'First retrieve the settings
  182.     txtServerName.Text = GetSetting(gsAppName, "Startup", "ServerName", vbNullString)
  183.     cmdLogin.Enabled = True
  184. End Sub
  185.